#define  _CRT_SECURE_NO_WARNINGS
#include <string>
#include <stack>
using namespace std;

class Solution {
public:
    bool isValid(string s) {
        stack<char> st;
        for (auto ch : s)
        {
            if (ch == '(' || ch == '[' || ch == '{')
                st.push(ch);
            else
            {s
                if (st.empty()) return false;
                if (st.top() == '(' && ch == ')'
                    || st.top() == '[' && ch == ']'
                    || st.top() == '{' && ch == '}')
                {
                    st.pop();
                }
                else return false;
            }
        }
        return st.empty();
    }
};